<?php

/*
 *      Copyright 2008 bpx <bpx@broken-paradox.com>
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

/* 
 * Add any additional includes here if you create more
 * elements to be integrated into the main template.
 */ 
include('db.php');
include('session.php');
include('includes/layout.php');
include('viewPosts.php');

$session = new Session();

layout::header();
layout::beginMain();

$dbcon = $_SESSION['db']->getInstance();

$getPosts = new viewPosts($dbcon);

$numPosts = (int)$getPosts->getNumPosts();
if (isset($_POST['id']))	{
	$pId = (int)$_POST['id'];
}
else if (isset($_GET['id']))	{
	$pId = (int)$_GET['id'];
}
else	{
	$pId = (int)1;
}

if (is_int($pId) && $pId > 0 && $pId <= $numPosts)	{
	$posts = $getPosts->getPost($pId);
	layout::postDetailed($posts);
}

else {
	echo "<p>Not a valid post.</p>";
}

layout::endMain();
layout::nav();
layout::footer();


?>



<!-- Spacer div -->
<div><br/><br/></div>

</body>

</html> 
